import { reqGetCategoryList, getMockBannerList, getMockFloorList } from "@/api";
const state = {
  categoryList: [],
  bannerList: [],
  floorList: [],
};
const mutations = {
  //获取分类列表
  GETCATEGORYLIST(state, list) {
    state.categoryList = list;
  },
  // 顶部轮播图
  GETBANNERLIST(state, data) {
    state.bannerList = data;
  },
  GETFLOORLIST(state, data) {
    state.floorList = data;
  },
};
const actions = {
  //获取分类列表
  async getCategoryList({ commit }) {
    const result = await reqGetCategoryList();
    result.code === 200 && commit("GETCATEGORYLIST", result.data.slice(0, 15));
  },
  //顶部轮播图
  async getBannerList({ commit }) {
    const result = await getMockBannerList();
    result.code === 200 && commit("GETBANNERLIST", result.data);
  },
  //底部部轮播图
  async getFloorList({ commit }) {
    const result = await getMockFloorList();
    result.code === 200 && commit("GETFLOORLIST", result.data);
  },
};
const getters = {};
export default {
  state,
  mutations,
  actions,
  getters,
};
